home *** CD-ROM | disk | FTP | other *** search
- * ============================================================================ *
- * ThinBevel: Draws a bevel box, given a rectangle and colors.
- *
- * ThinBevel(rp, ibox, ulpen, lrpen);
- * a1 a0 d0 d1
- *
- * This function uses PolyDraw to quickly render a bevel box. The horizontal
- * thickness of the vertical lines (1) and the vertical thickness of the
- * horizontal lines (1) has been hard-coded for speed.
- * ============================================================================ *
-
- include "exec/types.i"
- include "intuition/intuition.i"
- include "macros.i"
-
- SECTION quickbevel.asm,CODE
-
- far data
-
- xdef _ThinBevel,ThinBevel
-
- xref _LVOSetAPen,_LVOMove,_LVOPolyDraw,_GfxBase
-
- qregs reg d2-d7/a2/a6
-
- _ThinBevel:
- move.l 4(sp),a1 ; RastPort
- move.l 8(sp),a0 ; IBox
- move.l 12(sp),d0 ; upper left pen
- move.l 16(sp),d1 ; lower left pen
- ThinBevel:
- movem.l qregs,-(sp)
- move.l d1,d2 ; d2 <-- lrpen
- move.l a1,a2 ; a2 <-- copy of RP
- move.l _GfxBase,a6 ; a6 register
-
- moveq #0,d4 ; clear upper half of regs
- moveq #0,d5
- moveq #0,d6
- moveq #0,d7
- movem.w (a0),d4/d5/d6/d7 ; d4 <-- ibox_Left
- ; d5 <-- ibox_Top
- ; d6 <-- ibox_Width
- ; d7 <-- ibox_Height
- add.w d4,d6 ; d6 <-- right
- add.w d5,d7 ; d7 <-- bottom
- subq.w #1,d6 ; d6 <-- left - 1
- subq.w #1,d7 ; d7 <-- bottom - 1
-
- ;---------- draw upper left part
-
- move.w d5,-(sp) ; coords[7] (y) = TOP
- subq.w #1,d6 ; subtract 1 from RIGHT
- move.w d6,-(sp) ; coords[6] (x) = RIGHT-1
-
- move.w d5,-(sp) ; coords[5] (y) = TOP
- move.w d4,-(sp) ; coords[4] (x) = LEFT
-
- ; move.l d0,d0 ; upper left pen color
- move.l a2,a1 ; a1 <-- rp
- jsr _LVOSetAPen(a6) ; set it
-
- move.l d4,d0 ; d0 <-- LEFT
- move.l d7,d1 ; d1 <-- BOTTOM
- subq.w #1,d1 ; d1 <-- BOTTOM-1
- move.l a2,a1 ; a1 <-- rp
- jsr _LVOMove(a6) ; Move to cursor coords
-
- moveq #2,d0 ; draw 4 points
- move.l sp,a0 ; address of coords
- move.l a2,a1 ; a1 <-- rp
- jsr _LVOPolyDraw(a6) ; draw the line
-
- lea 8(sp),sp
-
- ;---------- draw lower right part
-
- addq.w #1,d6 ; d6 <-- RIGHT (fix from before)
-
- move.w d7,-(sp) ; coords[7] (y) = BOTTOM
- move.w d4,-(sp) ; coords[6] (x) = LEFT + 1
-
- move.w d7,-(sp) ; coords[5] (y) = BOTTOM
- move.w d6,-(sp) ; coords[4] (x) = RIGHT
-
- move.l d2,d0 ; lower right pen color
- move.l a2,a1 ; a1 <-- rp
- jsr _LVOSetAPen(a6) ; set it
-
- move.l d6,d0 ; d0 <-- RIGHT
- move.l d5,d1 ; d1 <-- TOP
- addq.w #1,d1 ; d1 <-- TOP + 1
- move.l a2,a1 ; a1 <-- rp
- jsr _LVOMove(a6) ; Move to cursor coords
-
- moveq #2,d0 ; draw 4 points
- move.l sp,a0 ; address of coords
- move.l a2,a1 ; a1 <-- rp
- jsr _LVOPolyDraw(a6) ; draw the line
-
- lea 8(sp),sp
-
- movem.l (sp)+,qregs
- rts
-
- end
-
- /* original C code */
-
- ThinBevel(
- struct RastPort *rp, /* rastport */
- struct IBox *b, /* box to render into */
- int ulpen, /* upper-left pen */
- int lrpen ) /* lower-right pen */
- { WORD coords[8]; /* coordinates to draw */
- int bottom,
- right;
-
- bottom = b->Top + b->Height - 1;
- right = b->Left + b->Width - 1;
-
- /* upper left edges */
-
- coords[0] = b->Left;
- coords[1] = b->Top;
- coords[2] = right-1;
- coords[3] = b->Top;
-
- SetAPen( rp, ulpen );
- Move( rp, b->Left, bottom-1 );
- PolyDraw(rp,2,coords);
-
- /* lower right edges */
-
- coords[4] = right;
- coords[5] = bottom;
- coords[6] = b->Left + 1;
- coords[7] = bottom;
-
- SetAPen( rp, lrpen );
- Move( rp, right, top+1 );
- PolyDraw(rp,4,coords);
- }
-